window.onload = function() {
	guanggao();
	nav();
	jingcaihuodong();
	//	setTimeout("nav()",1000)
	//	setInterval(bannertp(),1000);
	setInterval(bannertp, 1500);
	//	bannertp();
	hsq();
	remenmudidi();
}

/*-----------------------------nav下拉列表显示与隐藏效果------------------------------------*/
function nav() {
	var nav = document.getElementsByClassName("nav_li1");
	for(var i = 0; i < nav.length; i++) {
		//		console.log(i)
		//自增一个属性index保存为i，函数结束不会消失   
		nav[i].index = i;
		nav[i].onmouseover = function() {
			//this 等价于nav[i]
			var index = this.index;
			document.getElementsByClassName("nav_ul2")[index].style.display = "block";
		}
		nav[i].onmouseout = function() {
			//this 等价于nav[i]
			var index = this.index;
			document.getElementsByClassName("nav_ul2")[index].style.display = "none";
		}

		//闭包写法
		//		nav[i].onmouseover = (function (j){
		//			return function() {
		//				document.getElementsByClassName("nav_ul2")[j].style.display="block";
		//			};
		//		})(i);
		//		nav[i].onmouseout = (function (j){
		//			return function() {
		//				document.getElementsByClassName("nav_ul2")[j].style.display="none";
		//			};
		//		})(i);
	}

}

/*-----------------------banner图轮播效果--------------------------*/

function bannertp() {
	var b = document.getElementsByClassName("banner-inner")[0].children[0];
	var anniu = document.getElementsByClassName("banner-li");
	var banner_length = 4;
	//banner图片切换
	var bList = b.src.split("/");
	var a = bList[bList.length - 1].split(".")[0];
	a = Number(a) + 1;
	if(a > banner_length) {
		a = 1;
	};
	b.src = "img/" + a + ".jpeg";
	
	//图片按钮切换
	for(var i = 0; i < anniu.length; i++) {
		anniu[i].style.backgroundColor = "#ccc"
//		anniu[i].onclick=function(){
//			var index = i+1;
//			b.src = "http://127.0.0.1:8020/乡村旅游Web项目/img/" + index + ".jpeg";
//		}
		if(i == a - 1) {
			anniu[i].style.backgroundColor = "#2E8B57";
			anniu[i].style.opacity = "1";
		}
	}
};
//banner图片切换路径为绝对路径
//function bannertp () {
//	var elem = document.getElementsByClassName("banner-inner")[0].getElementsByTagName("img")[0];
//	var img_count = 4;
//	var imgArray = elem.src.split("/");
//	var i = imgArray[imgArray.length - 1].split(".")[0];
//	i = (Number(i) + 1);
//	if(i > img_count) {
//		i = 1;
//	}
//	elem.src = "http://127.0.0.1:8020/乡村旅游Web项目/img/" + i + ".jpeg";
//}











/*--------------------------精彩活动鼠标移入黑影特效--------------------------------*/


function jingcaihuodong(){
	var div = document.getElementsByClassName("heiying");
	var leftDiv = document.getElementsByClassName("jingcaihuodong-main-left-div");
	
	for (var i = 0,len=leftDiv.length; i < len; i++){
//		div[i].style.marginTop="0px";
//		div[i].index = i;
		leftDiv[i].index = i;
		leftDiv[i].onmouseenter=function(){
			var index = this.index
			/*div[this.index].style.marginTop = "0px";   */
			var value=158;
			
			var timer=setInterval(function(){
				
				div[index].style.marginTop =value+"px";
				value-=4;
				if(value<0){
				  clearInterval(timer);
				}
			},10);
			 
		}
		
		leftDiv[i].onmouseleave=function(){
			var index = this.index
//          div[this.index].style.marginTop = "148px";  
			var value=0;
			var timer = setInterval(function(){
				div[index].style.marginTop = value+"px"  
				value+=4;
				if (value>158) {
					clearInterval(timer);
				}
			},10)
		}
	}	
}

/*-------------------------和谁去左面特效-----------------------------------------------*/

function hsq(){
	var li = document.getElementsByClassName("main-main-left-ul")[0].getElementsByTagName("li");
	
	for (var i = 0,len=li.length; i < len; i++) {
		li[i].onmouseover=function(){
			
			
			this.style.zIndex=10;
			var h=52.5;
			var that=this;
			
			
			var timer1=setInterval(function(){
				
				that.style.height=h+"px";
				h+=2;
				if(h>145){
					clearInterval(timer1);
				}
			},10)
					
			
			
//			this.style.height="145px"
//			var value = 0;
//			var a = this;
			
//			var tmer = setInterval(function(){
//				a.style.height=value+"px";
//				value+=2;
//				if (value>145) {
//					clearInterval(tmer)
//				}
//			},10)
						
		}
		li[i].onmouseout=function(){
			
			var h=145;
			var that=this;
			that.style.zIndex=1;
			var timer2=setInterval(function(){
				that.style.height=h+"px";
				h-=2;
				if(h<52.5){
					clearInterval(timer2);
				}
			},10)
			
//			var  value = 145;
//			var a = this
//			var tmer = setInterval(function(){
//				a.style.height=value+"px";
//				if (value<52.5) {
//					clearInterval(tmer);
//				}
//			},10)
		}
	}

}

/*--------------------------热门目的地和推荐景区特效---------------------------------------*/


function remenmudidi(){
	var box = document.getElementsByClassName("remenmudidi-main");
	for (var i = 0; i < box.length; i++) {
		
		var a = box[i].getElementsByTagName("li");//获取到每行的容器
		
		for (var j = 0; j < a.length; j++) {
			a[j].index=j;
			a[j].onmouseover=function(){
//				var index =this.index
//				var div =a[i].getElementsByTagName("div");
//				div[index].style.top="166px"
				
			}
		}
		var div =box[i].getElementsByTagName("div");
		console.log(a)
		console.log(div)
	}
	
	


	/*----------------------------登陆区全屏滚动-------------------------------*/
//	$(function(){
//		$('#dowebok').fullpage({
//			sectionsColor: ['#1bbc9b', '#4BBFC3', '#7BAABE', '#f90'],
//			continuousVertical: true
//		});
//	});
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
//	var box = document.getElementsByClassName("remenmudidi-main")[0].getElementsByTagName("li");
//	var div = document.getElementsByClassName("remenmudidi-main")[0].getElementsByTagName("div");
//	for (var i = 0,len=box.length; i < len; i++) {
//		box[i].index=i;
//		var a = box[i].index
//		box[a].onmouseover=function(){
//			var b = 0;
//			var timer1 = setInterval(function(){
//				b+=2;
//				div[].style.top=b+"px";
//				if (b>144) {
//					clearInterval(timer1)
//				}
//			},10)
//			
//			
//		}
//	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}































/*------------------------------页面底部广告点击关闭效果--------------------*/
function guanggao() {
	document.getElementsByClassName("bottom-end")[0].onclick = function() {
		document.getElementsByClassName("bottom")[0].style.display = "none";
	}
}